﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyDiskInfo.Service
{
    public class ConfigUtil
    {
        #region 字段
        /// <summary>
        /// 固态硬盘名称
        /// </summary>
        public static string SSDCaption { get { return ConfigurationManager.AppSettings["SSDCaption"]; } }
        /// <summary>
        /// LBA(逻辑区块地址)今日写入量
        /// </summary>
        public static string LBATodayWrite { get { return ConfigurationManager.AppSettings["LBATodayWrite"]; } }
        #endregion

        #region 保存配置
        /// <summary>
        /// 保存配置
        /// </summary>
        public static void Save(string key, string value)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings[key].Value = value;
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
        }
        #endregion

    }
}
